#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
FastAPI 服务器启动脚本
"""

import uvicorn
import sys
import os

def main():
    """启动FastAPI服务器"""
    print("🚀 启动黄金投资分析API服务器...")
    print("📖 API文档地址: http://localhost:8000/docs")
    print("🔄 ReDoc文档地址: http://localhost:8000/redoc")
    print("💰 服务状态: http://localhost:8000/")
    print("🏥 健康检查: http://localhost:8000/health")
    print("-" * 50)
    
    # 检查配置文件
    if not os.path.exists("config.json"):
        print("⚠️  警告: 未找到config.json配置文件")
        print("📝 请参考config.example.json创建配置文件")
        print("🔑 确保包含有效的openai_api_key")
        print("-" * 50)
    
    try:
        uvicorn.run(
            "app:app",
            host="0.0.0.0",
            port=8000,
            reload=True,
            log_level="info"
        )
    except KeyboardInterrupt:
        print("\n👋 服务器已停止")
    except Exception as e:
        print(f"❌ 启动失败: {e}")
        sys.exit(1)

if __name__ == "__main__":
    main()
